<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <title>编辑广告表</title>
  <div th:replace="common/link::header"></div>
</head>
<body>
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-header">基本信息</div>
    <div class="layui-card-body">
      <div class="layui-row">
        <div class="layui-form layui-form-pane" lay-filter="ad_form" id="ad_form">
          <input type="hidden" name="id" id="id">
          <div class="layui-form-item">
            <label class="layui-form-label">图片</label>
            <div style="width: 1000px">
              <div class="layui-upload">
                <input type="hidden" id="picture" name="picture">
                <div class="layui-upload-list" id="img_upload">
                  <p id="upload-img-text"></p>
                </div>
              </div>
            </div>
          </div>
          <div class="layui-form-item" style="text-align: center">
            <div class="layui-btn-group">
              <button type="button" class="layui-btn layui-btn-primary" id="upload-img-btn">上传
              </button>
              <button type="button" class="layui-btn layui-btn-primary" id="clear-img-btn">清除
              </button>
            </div>
          </div>
          <!--layui-disabled是不可修改的css样式放在input里的-->
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">线路编号</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="lineNo" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">线路名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="lineName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">序列号</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="sNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">门翼编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="GPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">门翼名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="GPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">读写器编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="RPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">读写器名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="RPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">磁模块编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="MPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">磁模块名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="MPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">显示屏编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="DPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">显示屏名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="DPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">通行控制单元编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="CPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">通行控制单元名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="CPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">备用电源编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="EPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">备用电源名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="EPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">数据存储卡编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="SPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">数据存储卡名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="SPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">编码器编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="CoPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">编码器名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="CoPartName"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">工控机编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="IpcPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">工控机名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="IpcPartName"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">二维码识读模块编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="QrPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">二维码识读模块名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="QrPartName"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">人脸图像采集模块编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="FPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">人脸图像采集模块名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="FPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">旅行证件识读模块编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="TPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">旅行证件识读模块名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="TPartName" />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">电机驱动器编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="MdPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">电机驱动器名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="MdPartName"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">测量光幕编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="MlPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">测量光幕名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="MlPartName"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">安全光幕编码</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="SlPartNumber"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 180px">安全光幕名称</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="SlPartName"
              />
            </div>
          </div>
          <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="save-submit" id="save-submit" value="确认">
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<div th:replace="common/script::footer"></div>
<script th:inline="javascript">
  layui.config({
    base: '/static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index', //主入口模块
  }).use(['index', 'form', 'crud', 'upload'], function () {
    let $ = layui.$,
            form = layui.form,
            crud = layui.crud,
            upload = layui.upload,
            ad = [[${ad}]];
    // 回显图片
    //$('#upload-img0').attr('src', ad.picture).show();
    if (ad.picture == null) {
      $('#img_upload img').remove();
    } else {
      let src_P = ad.picture.split(",");
      for (let j in src_P) {
        $("#img_upload").append('<img id="'+j+'" style="width: 100px;height: 100px;padding: 5px;float: left;" onclick="fun.preview(this)" src="'+src_P[j]+'">');
        //$('#upload-img' + j).attr('src', src_P[j]).show();
      }
    }
    form.val('ad_form', ad);
    // 编辑
    form.on('submit(save-submit)', function (data) {
      //data.field.picture = crud.getPictureData();
      $.ajax({
        type: 'POST',
        url: ctx + '/app/notice/modify',
        data: JSON.stringify(data.field),
        contentType: 'application/json;charset=UTF-8',
        dataType: 'json',
        success: function (result) {
          layer.msg(result.message);
          if (result.code === 200) {
            let index = parent.layer.getFrameIndex(window.name);
            // 关闭
            parent.layer.close(index);
            // 刷新
            parent.location.reload();
          }
        }
      });
    });
    //普通图片上传
    crud.uploadImg("picture");
  });
</script>
</body>
</html>